let houseId;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dialogVisible: false,
    houseList: []
  },
  async onLoad() {
    this.gethouseList()
    // console.log(res);
  },
  async gethouseList() {
    const res = await wx.http({ url: '/room' })
    // console.log(res)
    this.setData({
      houseList: res.data,
    })
  },
  goDetail(ev) {
    wx.navigateTo({
      url: '/house_pkg/pages/detail/index?id=' + ev.mark.id
    })
  },
  swipeClose(ev) {
    this.setData({
      dialogVisible: true
    })
    const { instance } = ev.detail
    instance.close()
    houseId = ev.mark.id
  },
  async dialogClose(ev) {
    if (ev.detail === 'confirm') {
      await wx.http({
        url: '/room/' + houseId,
        method: 'delete'
      })
      this.gethouseList()
    }
  },
  addHouse() {
    wx.navigateTo({
      url: '/house_pkg/pages/locate/index',
    })
  }
})